package com.warmlight.voicepacket.ui.imlm.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.warmlight.voicepacket.ui.imlm.fragment.TeaseHotFragment;

import java.util.ArrayList;
import java.util.Map;

public class GoodListenerTeaseViewpagerAdapter extends FragmentPagerAdapter {

    private ArrayList<Map<String,String>> titles;

    public GoodListenerTeaseViewpagerAdapter(FragmentManager fm,ArrayList<Map<String,String>> a) {
        super(fm);
        this.titles = a;
    }

    @Override
    public Fragment getItem(int position) {
        Map<String, String> map = titles.get(position);
        String id = map.get("id");
        TeaseHotFragment fragment = new TeaseHotFragment();
        Bundle bundle = new Bundle();
        bundle.putString("id",id);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getItemPosition(Object object) {
//        return super.getItemPosition(object);
        return POSITION_NONE;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position).get("title");
    }

    @Override
    public int getCount() {
        return titles.size();
    }
}
